package com.itcam;

import java.util.Scanner;

/**
 * @author : Cammy.Wu
 * Description : 
 */

public class Demo03 {

    public static void main(String[] args) {
        try {
            Scanner scanner = new Scanner(System.in);

            System.out.println("请输入数字A：");
            double numberA = Double.parseDouble(scanner.nextLine());
            System.out.println("请选择运算符（+、-、*、/）");
            String operation = scanner.nextLine();
            System.out.println("请输入数字B：");
            double numberB = Double.parseDouble(scanner.nextLine());
            double result = com.itcam.Operation01.getResult(numberA, numberB, operation);


            System.out.println("结果是：" + result);
        } catch (NumberFormatException e) {
            System.out.println("输入有误" + e.toString());
        }
    }

}

class Operation01 {
    public static double getResult(double numberA, double numberB, String operation) {
        double result = 0d;
        switch (operation) {
            case "+":
                result = numberA + numberB;
                break;
            case "-":
                result = numberA - numberB;
                break;
            case "*":
                result = numberA - numberB;
                break;
            case "/":
                result = numberA - numberB;
                break;
        }
        return result;
    }
}
